<admintpl file="header" />
<style>
.col-md-6{width:45%;}
.first_div{margin-top:50px;}
</style>
</head>
<body>
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:U('BimModel/index')}">{:L('ADMIN_BIMMODEL_INDEX')}</a></li>
            <li ><a href="{:U('BimModel/add')}">{:L('ADMIN_BIMMODEL_UPLOAD')}</a></li>
			<li class="active"><a href="{:U('BimModel/add_version')}">{:L('ADMIN_BIMMODEL_ADD_VERSION')}</a></li>
        </ul>
        <form method="post" class="form-horizontal js-ajax-form" action="{:U('BimModel/add_version_post')}"  enctype="multipart/form-data">
           
			<div class="form-group first_div">
                <label class="col-md-2 control-label"><span style="color:red;"> * </span>{:L('CONSTRUCTION')}</label>
                <div class="col-md-6">
                    <select name="construction_id" id="const" class="form-control">
                        <option value="1">方案阶段</option>
                        <option value="2">扩初阶段</option>
                        <option value="3">施工图阶段(设计)</option>
						<option value="4">施工图阶段(施工)</option>
                    </select>
                </div>
            </div>
			<div class="form-group">
                <label class="col-md-2 control-label">{:L('VERSIONS')}</label>
                <div class="col-md-6">
                    <select name="version_id" class="form-control" id="version_id">
                        <foreach name="versions" item="vo">
                            <option value="{$vo.id}">{$vo.version_name}</option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label"><span style="color:red;"> * </span>{:L('NEW_VERSION')}</label>
                <div class="col-md-6">
                    <input type="text" class="form-control" name="version_name" placeholder="请输入新版本号">
                </div>
            </div>
            

            <div class="form-actions col-md-10 col-md-offset-2">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:L('ADD')}</button>
                <a class="btn btn-default" href="javascript:history.back(-1);">{:L('BACK')}</a>
            </div>
        </form>
    </div>
	<script src="__PUBLIC__/js/common.js"></script>
    <script>
	$(document).ready(function(e) {
			$("#const").on("change", function(){
				getSelectVal();
			});
			function getSelectVal(){
				$.getJSON("{:U('BimModel/get_versions')}",{construction_id:$("#const").val()},function(json){ 
					var version_id = $("#version_id"); 
					$("option",version_id).remove(); //清空原有的选项 
					$.each(json,function(index,array){ 
						var option = "<option value='"+array['id']+"'>"+array['version_name']+"</option>"; 
						version_id.append(option); 
					}); 
				});
			}
			
	});
	</script>
</body>
</html>